{extend name="user:base" /}
{block name="main"}
<!-- begin::main content -->
<main class="main-content">
    <div class="page-header d-md-flex justify-content-between align-items-center">
        <div>
            <h4>发布动态</h4>
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="#">默认第一行为动态的标题</a></li>
                </ol>
            </nav>
        </div>
    </div>
    <div class="bgfff">
       <div class="col-xs-12 col-md-12">
                    <div class="layui-tab layui-tab-brief" lay-filter="user">
                        <ul class="layui-tab-title" id="LAY_mine">
                            <li class="layui-this" lay-id="info">发布动态</li>
                        </ul>
                        <div class="layui-tab-content" style="padding: 20px 0;">
                            <div class="layui-form layui-form-pane layui-tab-item layui-show">
                                <form method="post" class="layui-form">

                                    <div class="layui-form-item layui-form-text">
                                        <div class="layui-input-block">
                                            <textarea placeholder="随便写些什么刷下存在感" id="L_sign"  name="info" autocomplete="off" class="layui-textarea" ></textarea>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <button class="layui-btn" key="set-mine" lay-submit lay-filter="info">立即发布</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
        </div>
    </div>
</div>
</main>

<script>
    //Demo
    layui.use(['form','layedit'], function(){
        var form = layui.form;
        var layedit = layui.layedit;
        layedit.set({
            uploadImage: {
                url: '{:url("Upload/layedit")}' //接口url
                ,type: '' //默认post
            }
        });
        edit = layedit.build('L_sign',
            {tool: [  'strong', '|', 'face','|','image']}
        ); //建立编辑器
        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            return false;
        });

        form.on('submit(info)', function(data){
            var url = "{:url('news/save')}";
            info = layedit.getContent(edit);
            if(!info){
                error("请填写内容");
                return false;
            }
            $.post(url,{info:info},function (e) {
                if(e.code ==200){
                    success(e.msg);
                    setTimeout("location.reload()",2000)
                }else {
                    error(e.msg);
                }
            })
            return false;
        });
    });

</script>
{/block}